import java.io.PrintStream;


public class Tarea implements Runnable{
	
	private final String mensaje;
	private final int pausaIniciar;
	private final int numIteracions;
	private final int pausaIteracions;
	private final PrintStream metode;
	
	
	public Tarea(String mensaje, int pausaIniciar, int numIteracions, int pausaIteracions, PrintStream metode){
		this.mensaje=mensaje;
		this.pausaIniciar=pausaIniciar;
		this.numIteracions=numIteracions;
		this.pausaIteracions=pausaIteracions;
		this.metode=metode;
	}
	
	@Override
	public void run() {
		try {
			Thread.sleep(pausaIniciar);
		} catch (InterruptedException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		for (int i = 0; i < numIteracions; ++i) {
			metode.println("["+Thread.currentThread().getId()+"] " + mensaje );
			try {
				Thread.sleep(pausaIteracions);
			} catch (InterruptedException e) {
				metode.println("Error: " + e.toString());
			}
		}
		
	}
	
	
}
